Skip to main content

ser.loc[]

ser.loc[label]

Returns the element of the Series that corresponds to its row label.

Note:
  • Often ser comes from df.get(column_name).
  • In DSC 10, we only use loc and iloc on Series, and never on DataFrames. That's because we want to avoid working with row objects, which contain data of varying types. To extract something from a data frame, you should always use get first to grab the column as a series, then use loc or iloc to get the individual entry.

species_ser
  • dog_001"dog"
  • cat_001"cat"
  • cat_002"cat"
  • dog_002"dog"
  • dog_003"dog"
  • ham_001"hamster"
  • ham_002"hamster"
  • cat_003"cat"
species_ser.loc['dog_002']

'dog'


Problems or suggestions about this page? Fill out our feedback form.